package com.trade.wzj.service.yang.impl;

import java.util.List;

import com.trade.wzj.dao.yang.SupplierInfoDao_Yang;
import com.trade.wzj.model.xiang.SupplierInfo;
import com.trade.wzj.service.yang.SupplierInfoService_Yang;

public class SupplierInfoImpl_Yang implements SupplierInfoService_Yang {
	
	private SupplierInfoDao_Yang supplierInfoDao;
	
	public SupplierInfoDao_Yang getSupplierInfoDao() {
		return supplierInfoDao;
	}

	public void setSupplierInfoDao(SupplierInfoDao_Yang supplierInfoDao) {
		this.supplierInfoDao = supplierInfoDao;
	}
 


	/**
	 * 查询供应商基本信息
	 */
	@Override
	public List<SupplierInfo> findSupplier(String name) throws Exception {
		List<SupplierInfo> list = null;
		try {
			list = supplierInfoDao.findSupplier(name);
		} catch (Exception e) {
			throw new Exception();
		}
		return list;
	}

	/**
	 * 通过id查询供应商基本信息
	 */
	@Override
	public SupplierInfo getSupplierInfoById(Integer id) throws Exception {
		SupplierInfo sup = null;
		String msg="";
		try {
			if(null!=id) {
				sup=supplierInfoDao.getSupplierInfoById(id);
			}else {
				msg="id为空，查询失败";
				throw new Exception(msg);
			}
			
		} catch (Exception e) {
			msg="查询失败";
			throw new Exception(msg);
		}
		return sup;
	}

	//修改供应商基本信息
	@Override
	public void updateSupplier(SupplierInfo supplier) throws Exception {
		try {
			if(supplier.getSupplierInfoID()!=null) {
				supplierInfoDao.updateSupplier(supplier);
			}else {
				throw new Exception("id为空，修改失败");
			}
		} catch (Exception e) {
			throw new Exception("修改失败!");
		}
	}

}
